package com.jiunuan.live.api.controller;

import com.jiunuan.live.api.service.IUserLoginService;
import com.jiunuan.live.common.interfaces.vo.WebResponseVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author jiunuan
 * @Date: Created in 11:13 2024/8/7
 * @Description 登录相关接口
 }
 */
@RestController
@RequestMapping("/userLogin")
@Tag(name = "userLogin-用户登录相关接口")
public class UserLoginController {

    @Resource
    private IUserLoginService userLoginService;

    //发送验证码
    @Operation(summary = "sendLoginCode-发送验证码")
    @PostMapping("/sendLoginCode")
    public WebResponseVO sendLoginCode(String phone) {
        return userLoginService.sendLoginCode(phone);
    }

    @Operation(summary = "login-登录请求")
    //登录请求 验证码是否合法 -> 初始化注册/老用户登录
    @PostMapping("/login")
    public WebResponseVO login(String phone, Integer code, HttpServletResponse response) {
        return userLoginService.login(phone, code, response);
    }
}